package com.wzn;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

import net.sf.json.JSONObject;

/**
 * Servlet implementation class TestServlet
 */
public class TestServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public TestServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		Student student = new Student();
		student.setAge(2123112332);
		student.setName("黄飞鸿");
		student.setSex("男");

		Student student2 = new Student();
		student2.setAge(21232);
		student2.setName("黄飞123213鸿");
		student2.setSex("男");

		Student student3 = new Student();
		student3.setAge(22153432);
		student3.setName("黄飞213鸿");
		student3.setSex("男");

		Student student4 = new Student();
		student4.setAge(22);
		student4.setName("黄飞鸿");
		student4.setSex("男312");

		List<Student> list = new ArrayList<Student>();
		list.add(student);
		list.add(student2);
		list.add(student3);
		list.add(student4);

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("result", list);

		JSONObject json=JSONObject.fromObject(map);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println(request.getParameter("mdval"));
	}

}
